/**
 * @filename:UserServiceImpl 2019-01-17 14:56:43
 * @project skz  V1.3.3
 * Copyright(c) 2018 Liu,Wenzhao Co. Ltd. 
 * All right reserved. 
 */
package com.bingsum.service;

import com.bingsum.annotation.Api;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;

import com.bingsum.model.User;
import com.bingsum.mapper.UserMapper;

/**   
 *  
 * @Description:  [用户信息]——SERVICE
 * @Author:       Liu,Wenzhao   
 * @CreateDate:   2019-01-17 14:56:43
 * @Version:      V1.3.3
 *    
 */
@Service("userService")
@Transactional(readOnly = true)
public class UserService{

    @Autowired
    private UserMapper userMapper;

    @Api
    public User getUserInfo(String openid) {
        return userMapper.getUserInfo(openid);
    }

    @Api
    @Transactional(readOnly = false)
    public int addUserInfo(User user) {
        System.out.println("success");
        int a = userMapper.addUserInfo(user);
        return a;
    }

    @Api
    @Transactional(readOnly = false)
    public int setUserInfo(User user) {
        int a =userMapper.setUserInfo(user);
        return a;
    }

    public User findByOpenId(String openId){
        User param = new User();
        param.setOpen_id(openId);
        User user = this.userMapper.selectOne(param);
        return user;
    }
}